<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let arrList = ['a', 'b', 'c', 'd', NaN];

        // 1.map方法
        arrList.map((item,index)=>{
            console.log(index+':'+item);
        })

        // 2.includes方法
        console.log(arrList.includes('a'));// T
        console.log(arrList.includes('e'));// F
        console.log(arrList.includes('c'));// T
        console.log(arrList.includes(NaN));// T


        // 关于深拷贝和浅拷贝
        // B复制A，如果A变B也跟着变，就是浅拷贝；A变B不受影响，完全独立于A，那么就是深拷贝


        // 3.filter方法:浅拷贝！！！
        let arrList2 = [1,2,3,4,5,6,7,8,9];
        // let arrList3 = arrList2.filter((item,index)=>{
        //     return item%2 === 0
        // })
        let arrList3 = arrList2.filter(item=>item%2 === 0)
        console.log(arrList3);

        let arrList4 = [
            {name:'wwj',sex:'女'},
            {name:'lyc',sex:'男'},
            {name:'ccy',sex:'女'},
            {name:'lby',sex:'男'},
        ]
        let arrList5 = arrList4.filter(item=>item.sex === '女');
        console.log(arrList5); // wwj:男，ccy:女
        arrList5[0].sex = '男';
        console.log(arrList4);
        console.log(arrList5); // wwj:男，ccy:女

        // 4.find方法：找符合条件的第一个元素（浅拷贝！！！）
        let x = arrList4.find(item=>item.name === 'wwj');
        let y = arrList4.find(item=>item.sex === '男');
        let z = arrList4.find(item=>item.name === 'xkm');
        console.log(x);// wwj:男
        console.log(y);// wwj:男
        console.log(z);// undefined

        x.sex = '女';
        console.log(arrList4);// wwj:女
        console.log(x);// wwj:女

    </script>
</head>
<body>
</body>
</html>